<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="crm.util.ParamUtil"%>
<%@page import="crm.model.Purchase"%>
<%@page import="crm.control.PurchaseControl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>purchase_add_do</title>
	</head>
	<body>
		<%
			request.setCharacterEncoding("UTF-8");
			Purchase purchase = new Purchase();

			String goods_name = ParamUtil.getString(request, "goods_name", null);
			purchase.setGoods_name(goods_name);

			Float single_price = ParamUtil.getFloat(request, "single_price");
			purchase.setSingle_price(single_price);

			int goods_num = ParamUtil.getInt(request, "goods_num", 0);
			purchase.setGoods_num(goods_num);

			Float sum_fee = ParamUtil.getFloat(request, "sum_fee");
			purchase.setSum_fee(sum_fee);

			String place = ParamUtil.getString(request, "place", null);
			purchase.setPlace(place);

			String time = ParamUtil.getString(request, "time", null);
			purchase.setTime(time);

			String person = ParamUtil.getString(request, "person", null);
			purchase.setPerson(person);

			String seller = ParamUtil.getString(request, "seller", null);
			purchase.setSeller(seller);

			String seller_contact = ParamUtil.getString(request,"seller_contact", null);
			purchase.setSeller_contact(seller_contact);
			
			int recepit_id = ParamUtil.getInt(request, "recepit_id", 0);
			purchase.setRecepit_id(recepit_id);
			System.out.println(recepit_id);

			if (PurchaseControl.addPurchase(purchase) != 0) {
		%>
		<script type="text/javascript">
if (window.confirm("添加采购记录成功，是否继续添加？"))
	window.top.location.href = "purchase_add.jsp?id=<%=recepit_id%>";
else
	window.top.location.href = "purchase.jsp?id=<%=recepit_id%>";
</script>
		<%
			} else {
		%>
		<script type="text/javascript">
if (window.confirm("添加采购记录失败，是否继续添加？"))
	window.top.location.href = "purchase_add.jsp?id=<%=recepit_id%>";
else
	window.top.location.href = "purchase.jsp?id=<%=recepit_id%>";
</script>
		<%
			}
		%>
	</body>
</html>